<?php

header("Content-Type:text/html;charset=utf-8");
error_reporting(0);
date_default_timezone_set('Asia/Shanghai');
$t1 = microtime(true);
$dbconfig = array(
"host"=>"127.0.0.1",
"dbname"=>"gps",
"port"=>3306,
"username"=>"root",
"password"=>''
);

try{
$db = new PDO("mysql:host={$dbconfig['host']};dbname={$dbconfig['dbname']};port={$dbconfig['port']}",$dbconfig['username'],$dbconfig['password']);
$db->exec("set names utf8");
}catch(Exception $e){

echo $e->getMessage();exit;
}
function query($db,$sql){
    $rs = $db->query($sql);
    if(!$rs){
        print_r($db->errorInfo());
        return false;
    }
    $rs->setFetchMode(PDO::FETCH_ASSOC);
    $data = array();

    while($row = $rs -> fetch()){
        $data[] = $row;
    }
return $data;
}

global $db;
/*$user = query($db,"SELECT * FROM gps_user");
var_dump($user);*/
